const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "自增id",
      field: "id"
    },
    order_no: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "订单号",
      field: "order_no"
    },
    order_detail_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "订单详情id",
      field: "order_detail_id"
    },
    order_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "订单id",
      field: "order_id"
    },
    goods_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "商品id",
      field: "goods_id"
    },
    user_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "用户id",
      field: "user_id"
    },
    system_type: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "default",
      primaryKey: false,
      autoIncrement: false,
      comment: "系统类型（默认 default, 其他按照SYSTEM_TYPE常量类型）",
      field: "system_type"
    },
    status: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "状态（0待确认, 1待退货, 2待审核, 3已完成, 4已拒绝, 5已取消）",
      field: "status"
    },
    type: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "业务类型（0仅退款, 1退货退款）",
      field: "type"
    },
    refundment: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "退款类型（0原路退回, 1退至钱包, 2手动处理）",
      field: "refundment"
    },
    reason: {
      type: DataTypes.CHAR(180),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "申请原因",
      field: "reason"
    },
    number: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "退货数量",
      field: "number"
    },
    price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "退款金额",
      field: "price"
    },
    msg: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "退款说明",
      field: "msg"
    },
    images: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "凭证图片（一维数组json存储）",
      field: "images"
    },
    refuse_reason: {
      type: DataTypes.CHAR(230),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "拒绝原因",
      field: "refuse_reason"
    },
    express_name: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "快递名称",
      field: "express_name"
    },
    express_number: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "快递单号",
      field: "express_number"
    },
    apply_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "申请时间",
      field: "apply_time"
    },
    confirm_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "确认时间",
      field: "confirm_time"
    },
    delivery_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "退货时间",
      field: "delivery_time"
    },
    audit_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "审核时间",
      field: "audit_time"
    },
    cancel_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "取消时间",
      field: "cancel_time"
    },
    add_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "添加时间",
      field: "add_time"
    },
    upd_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "更新时间",
      field: "upd_time"
    }
  };
  const options = {
    tableName: "sxo_order_aftersale",
    comment: "",
    indexes: [{
      name: "order_id",
      unique: false,
      type: "BTREE",
      fields: ["order_id"]
    }, {
      name: "goods_id",
      unique: false,
      type: "BTREE",
      fields: ["goods_id"]
    }, {
      name: "user_id",
      unique: false,
      type: "BTREE",
      fields: ["user_id"]
    }, {
      name: "status",
      unique: false,
      type: "BTREE",
      fields: ["status"]
    }, {
      name: "system_type",
      unique: false,
      type: "BTREE",
      fields: ["system_type"]
    }]
  };
  const SxoOrderAftersaleModel = sequelize.define("sxo_order_aftersale_model", attributes, options);
  return SxoOrderAftersaleModel;
};